<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
include_once(APPPATH."libraries/AdminController.php");

class Me extends AdminController {

	function __construct()
	{
		parent::__construct();
	}

	function index()
	{ 
		$this->_v("index",array());
	}
	
	function setting(){
		echo "disini setting";	
	}
	
	function change_password(){
		$pesan="";
		if(isset($_POST['btn_simpan'])){
			$pass_lama = md5(dbClean($_POST['pass_lama']));
			echo $pass_lama;
			$this->DATA->table="macs_user";
			$m1 = $this->DATA->_getall(array(
				"user_name"		=> $this->jCfg['user']['name'],
				"user_password"	=> $pass_lama
			));
			if(count($m1)>0){
				$pass_baru = md5(dbClean($_POST['pass_baru']));
				$mx = $this->DATA->_update(
					array(
						"user_name"		=> $this->jCfg['user']['name']
					),array(
						"user_password" => $pass_baru
					)
				);
				$pesan = ($mx)?"Password berhasil di update":"Password Gagal Di Update";
			}else{
				$pesan ="Password lama salah..";
			}
			
		}
		
		$this->_set_title('Profile > '.$this->jCfg['user']['fullname']);
		$this->_set_desc_title('Ganti Password');	
		$this->_v("change-password",array(
			"pesan"	=> $pesan
		));
	}
	
	function profile(){
		$this->_set_title('Profile > '.$this->jCfg['user']['fullname']);
		$this->_set_desc_title('Lihat Profile');	
		$this->load->model("mdl_employee","ME");
		$data = $this->ME->data( array(
								"column"	=> "employee_id",
								"keyword"	=>  $this->jCfg['user']['emp_id']
							) );
		if(count($data['data'])>0){
			$this->data_form = $data['data'][0];
		}
		$this->_v("profile",array());

	}
		
	function bug(){
		if(isset($_POST['btn_simpan'])){
			echo "<script>parent.location.reload(true);</script>";
		}
		$this->_v("report_bug",array(
			"url"	=> isset($_GET['url'])?$_GET['url']:''
		),FALSE);
	}
}

